<?php

/**
 * Application Models
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 * @copyright ZF model generator
 * @license http://framework.zend.com/license/new-bsd     New BSD License
 */

/**
 * Abstract class for models
 */
require_once 'ModelAbstract.php';

/**
 * 
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 */
class Application_Model_TypeEnseignement extends Application_Model_ModelAbstract
{

    /**
     * Database var type int(2)
     *
     * @var int
     */
    protected $_IdType;

    /**
     * Database var type varchar(20)
     *
     * @var string
     */
    protected $_Type;

    /**
     * Database var type varchar(8)
     *
     * @var string
     */
    protected $_Cin;



    /**
     * Dependent relation fk_etudiant_type_enseignement1
     * Type: One-to-Many relationship
     *
     * @var Application_Model_Etudiant
     */
    protected $_Etudiant;

    /**
     * Dependent relation fk_niveau_type_enseignement1
     * Type: One-to-Many relationship
     *
     * @var Application_Model_Niveau
     */
    protected $_Niveau;

    /**
     * Sets up column and relationship lists
     */
    public function __construct()
    {
        parent::init();
        $this->setColumnsList(array(
            'id_type'=>'IdType',
            'type'=>'Type',
            'cin'=>'Cin',
        ));

        $this->setParentList(array(
        ));

        $this->setDependentList(array(
            'FkEtudiantTypeEnseignement1' => array(
                    'property' => 'Etudiant',
                    'table_name' => 'Etudiant',
                ),
            'FkNiveauTypeEnseignement1' => array(
                    'property' => 'Niveau',
                    'table_name' => 'Niveau',
                ),
        ));
    }

    /**
     * Sets column id_type
     *
     * @param int $data
     * @return Application_Model_TypeEnseignement
     */
    public function setIdType($data)
    {
        $this->_IdType = $data;
        return $this;
    }

    /**
     * Gets column id_type
     *
     * @return int
     */
    public function getIdType()
    {
        return $this->_IdType;
    }

    /**
     * Sets column type
     *
     * @param string $data
     * @return Application_Model_TypeEnseignement
     */
    public function setType($data)
    {
        $this->_Type = $data;
        return $this;
    }

    /**
     * Gets column type
     *
     * @return string
     */
    public function getType()
    {
        return $this->_Type;
    }

    /**
     * Sets column cin
     *
     * @param string $data
     * @return Application_Model_TypeEnseignement
     */
    public function setCin($data)
    {
        $this->_Cin = $data;
        return $this;
    }

    /**
     * Gets column cin
     *
     * @return string
     */
    public function getCin()
    {
        return $this->_Cin;
    }

    /**
     * Sets dependent relations fk_etudiant_type_enseignement1
     *
     * @param array $data An array of Application_Model_Etudiant
     * @return Application_Model_TypeEnseignement
     */
    public function setEtudiant(array $data)
    {
        $this->_Etudiant = array();

        foreach ($data as $object) {
            $this->addEtudiant($object);
        }

        return $this;
    }

    /**
     * Sets dependent relations fk_etudiant_type_enseignement1
     *
     * @param Application_Model_Etudiant $data
     * @return Application_Model_TypeEnseignement
     */
    public function addEtudiant(Application_Model_Etudiant $data)
    {
        $this->_Etudiant[] = $data;
        return $this;
    }

    /**
     * Gets dependent fk_etudiant_type_enseignement1
     *
     * @param boolean $load Load the object if it is not already
     * @return array The array of Application_Model_Etudiant
     */
    public function getEtudiant($load = true)
    {
        if ($this->_Etudiant === null && $load) {
            $this->getMapper()->loadRelated('FkEtudiantTypeEnseignement1', $this);
        }

        return $this->_Etudiant;
    }

    /**
     * Sets dependent relations fk_niveau_type_enseignement1
     *
     * @param array $data An array of Application_Model_Niveau
     * @return Application_Model_TypeEnseignement
     */
    public function setNiveau(array $data)
    {
        $this->_Niveau = array();

        foreach ($data as $object) {
            $this->addNiveau($object);
        }

        return $this;
    }

    /**
     * Sets dependent relations fk_niveau_type_enseignement1
     *
     * @param Application_Model_Niveau $data
     * @return Application_Model_TypeEnseignement
     */
    public function addNiveau(Application_Model_Niveau $data)
    {
        $this->_Niveau[] = $data;
        return $this;
    }

    /**
     * Gets dependent fk_niveau_type_enseignement1
     *
     * @param boolean $load Load the object if it is not already
     * @return array The array of Application_Model_Niveau
     */
    public function getNiveau($load = true)
    {
        if ($this->_Niveau === null && $load) {
            $this->getMapper()->loadRelated('FkNiveauTypeEnseignement1', $this);
        }

        return $this->_Niveau;
    }

    /**
     * Returns the mapper class for this model
     *
     * @return Application_Model_Mapper_TypeEnseignement
     */
    public function getMapper()
    {
        if ($this->_mapper === null) {
            $this->setMapper(new Application_Model_Mapper_TypeEnseignement());
        }

        return $this->_mapper;
    }

    /**
     * Deletes current row by deleting the row that matches the primary key
     *
	 * @see Application_Model_Mapper_TypeEnseignement::delete
     * @return int|boolean Number of rows deleted or boolean if doing soft delete
     */
    public function deleteRowByPrimaryKey()
    {
        if ($this->getIdType() === null) {
            throw new Exception('Primary Key does not contain a value');
        }

        return $this->getMapper()
                    ->getDbTable()
                    ->delete('id_type = ' .
                             $this->getMapper()
                                  ->getDbTable()
                                  ->getAdapter()
                                  ->quote($this->getIdType()));
    }
}
